#include "Reading.h"

istream& operator >> (istream& ins, Reading& r)
{
	char lp, rp, cma;
	int h;
	double temp;

	ins >> lp >> h >> cma >> temp >> rp;
	if (!ins) 
		return ins;	
	else  if(lp!='('||cma!=','||rp!=')')
	{
		ins.clear(ios_base::failbit);
		return ins;
	}
	r.hour = h;
	r.temperature = temp;
	return ins;
}


ostream& operator << (ostream& outs, Reading& r)
{
	return outs << '(' << r.hour << ", " 
		<< r.temperature << ')';
}


bool operator == (const Reading& r1, const Reading& r2)
{
	return r1.temperature == r2.temperature;
}
bool operator != (const Reading& r1, const Reading& r2)
{
	return !(r1==r2);
}
bool operator <  (const Reading& r1, const Reading& r2)
{
	return (r1.temperature < r2.temperature);
}
bool operator <= (const Reading& r1, const Reading& r2)
{
	return (r1.temperature <= r2.temperature);
}
bool operator >= (const Reading& r1, const Reading& r2)
{
	return (r1.temperature >= r2.temperature);
}
bool operator >  (const Reading& r1, const Reading& r2)
{
	return (r1.temperature > r2.temperature);
}
